def prostoe(n):
    for d in range(2, n):
        if n % d == 0:
            return False
    return True

a = input().split()
if len(a) != 3:
    print('Wrong input')
else:
    sp_word = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
    if a[0] not in sp_word or a[1] not in sp_word or a[2] not in sp_word:
        print('Wrong input')
    else:
        ind1 = sp_word.index(a[0])
        ind2 = sp_word.index(a[1])
        ind3 = sp_word.index(a[2])
        if ind1 == 0:
            print('Wrong input')
        else:
            raz = []
            x = ind1 * 100 + ind2 * 10 + ind3
            for a in range(1, 1500):
                if prostoe(a):
                    raz.append([abs(x-a), a])
            raz.sort()
            print(raz[0][1])


